<cfscript>
	base = new assets.calgrants.com.Base();
	isWorkshopSeason = base.isWorkshopSeason();
	workshopGateway = new assets.calgrants.com.gateway.WorkshopGateway();
	workshops = workshopGateway.query(Organization_ID = request.authUser.organizationID, Program_Year = request.currentProgramYear, Manager_ID = IIf(IsUserInRole("Site Contact"), request.authUser.userID, ""));
</cfscript>

<cfif (IsUserInRole("Super User")) OR ((IsUserInRole("Organizer") OR IsUserInRole("Regional Admin")) AND isWorkshopSeason)>
	<p><a href="?view=editWorkshop&Workshop_ID=0" class="btn btn-success">New Workshop</a></p>
</cfif>

<cfif workshops.RecordCount gt 0>
	<table id="workshopsTable" class="table table-hover table-bordered">
		<thead>
			<tr>
				<th>Site</th>
				<th>Date/Time</th>
				<th>Wrapper Code</th>
				<th>Status</th>
				<th class="action"></th>
			</tr>
		</thead>
		<tbody>
			<cfoutput query="workshops">
				<tr>
					<td>#Site#</td>
					<td>#DateFormat(Workshop_Date, "m/d/yyyy")# #TimeFormat(Start_Time, "h:mmtt")#-#TimeFormat(End_Time, "h:mmtt")#</td>
					<td>#Evaluation_Code#</td>
					<td>
						<cfif Approved>
							Approved
						<cfelse>
							Pending Approval
						</cfif>
					</td>
					<td>
						<cfif IsUserInRole("Site Contact") OR Approved>
							<a href="?view=workshop&Workshop_ID=#Workshop_ID#" class="btn btn-success btn-block">View</a>
						<cfelse>
							<a href="?view=editWorkshop&Workshop_ID=#Workshop_ID#" class="btn btn-success btn-block">Edit</a>
						</cfif>
					</td>
				</tr>
			</cfoutput>
		</tbody>
	</table>
<cfelse>
	<div class="alert alert-info notFound">No registered workshops</div>
</cfif>

<!--- <cfset stubbed = true>

<cfif stubbed>
Stubbed
<cfelse>


<cfinvoke component="#request.pathToGateways#.WorkshopGateway" method="query" returnvariable="workshops">
	<cfif IsDefined("organizationID")>
		<cfinvokeargument name="Organization_ID" value="#organizationID#" />
	</cfif>
	<cfif IsDefined("userID")>
		<cfinvokeargument name="userIDs" value="#userID#" />
	</cfif>
</cfinvoke>

<cfscript>
	workshopGateway = new assets.calgrants.com.gateway.WorkshopGateway();
	//workshops = workshopGateway.query(Organization_ID = IIf();
</cfscript>

<cfif workshops.RecordCount gt 0>
	<table class="table table-striped table-bordered">
		<thead>
			<tr>
				<th>ID</th>
				<th>Site</th>
				<th>Date/Time</th>
				<th>Organizer</th>
				<th>Site Contact</th>
				<th>Students</th>
				<th>Status</th>
			</tr>
		</thead>
		<tbody>
			<cfoutput query="workshops" group="Program_Year">
				<tr>
					<td colspan="7"><strong>#Program_Year#</strong></td>
				</tr>
				<cfoutput>
					<tr>
						<td><a href="#script_name#?view=editWorkshop&workshopID=#Workshop_ID#">#Workshop_ID#</a></td>
						<td>#Site#</td>
						<td>#DateFormat(Workshop_Date, "m/d/yyyy")# #TimeFormat(Start_Time, "h:mmtt")#-#TimeFormat(End_Time, "h:mmtt")#</td>
						<td>
							<cfif Organizer_Approved>
								#Organizer_Full_Name#
							<cfelseif Organizer_Deleted>
								<font color="red">#Organizer_Full_Name#</font>
							<cfelseif Organizer_Archived>
								<font color="silver">#Organizer_Full_Name#</font>
							<cfelseif NOT Organizer_Approved>
								<font color="orange">#Organizer_Full_Name#</font>
							</cfif>
						</td>
						<td>
							<cfif Manager_Approved>
								#Manager_Full_Name#
							<cfelseif Manager_Deleted>
								<font color="red">#Manager_Full_Name#</font>
							<cfelseif Manager_Archived>
								<font color="silver">#Manager_Full_Name#</font>
							<cfelseif NOT Manager_Approved>
								<font color="orange">#Manager_Full_Name#</font>
							</cfif>
						</td>
						<td>
							<cfif Workshop_Date lt Now()>
								#Student_Count#
							</cfif>
						</td>
						<td>
							<cfif Approved>
								Approved
							<cfelseif Deleted>
								<font color="red">Deleted</font>
							<cfelseif NOT Approved>
								<font color="orange">Not Approved</font>
							</cfif>
						</td>
					</tr>
				</cfoutput>
			</cfoutput>
		</tbody>
	</table>
<cfelse>
	<div class="alert alert-info notFound">No workshops</div>
</cfif>

</cfif> --->